package com.atguigu.exer;
//例子：创建三个窗口卖票，总票数为100张
public class WindowsTest {
    public static void main(String[] args) {
        Windows windows1=new Windows();
        Windows windows2=new Windows();
        Windows windows3=new Windows();
        windows1.setName("窗口1");
        windows2.setName("窗口2");
        windows3.setName("窗口3");
        windows1.start();
        windows2.start();
        windows3.start();
    }
}
class Windows extends Thread{
    private static int ticket=100;
    public void run(){
        while(true){
            if(ticket>0){
                System.out.println(Thread.currentThread().getName()+":窗口1,票号为"+ticket);
                ticket--;
            }else{
                break;
            }
        }
    }
}
